package com.itboye.sunsun.adapter;

import java.text.SimpleDateFormat;
import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.sunsun.application.App;
import com.itboye.sunsun.beans.ShopCarBean.LuntanTieziHuiFuMe;
import com.itboye.sunsun.beans.WoDeZhuTiBean.ZhuTiItemBean;
import com.itboye.sunsun.constants.NetPublicConstant;
import com.itboye.sunsun.utils.XImageLoader;
import com.itboye.sunsunhome.R;

public class MessgeLuntanAdapter extends BaseAdapter {

	List<ZhuTiItemBean> dataList;

	public MessgeLuntanAdapter(List<ZhuTiItemBean> dataList) {
		this.dataList = dataList;
	}

	@Override
	public int getCount() {

		return dataList.size();
	}

	@Override
	public Object getItem(int position) {

		return null;
	}

	@Override
	public long getItemId(int position) {

		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(App.ctx).inflate(
					R.layout.item_huifu_wode, null);
			holder = new ViewHolder();
			holder.head = (ImageView) convertView.findViewById(R.id.head);
			holder.iv1 = (ImageView) convertView.findViewById(R.id.iv1);
			holder.iv2 = (ImageView) convertView.findViewById(R.id.iv2);
			holder.iv3 = (ImageView) convertView.findViewById(R.id.iv3);

			holder.name = (TextView) convertView.findViewById(R.id.name);
			holder.time = (TextView) convertView.findViewById(R.id.time);
			holder.content = (TextView) convertView.findViewById(R.id.content);
			holder.zan = (TextView) convertView.findViewById(R.id.zan);
			holder.commont = (TextView) convertView.findViewById(R.id.commont);

			holder.wohuifudepinglun = (TextView) convertView
					.findViewById(R.id.wohuifudepinglun);
			holder.imgsContainer = (ViewGroup) convertView
					.findViewById(R.id.imgsContainer);

			holder.tvname = (TextView) convertView.findViewById(R.id.tvname);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		ZhuTiItemBean bean = dataList.get(position);
		// try {
		// holder.head.setImageBitmap(null);
		XImageLoader.load(bean.getHead(), holder.head);
		// } catch (Exception e) {
		// }
		holder.name.setText(bean.getAuthor());

		holder.time.setText(new SimpleDateFormat("yyyy-MM-dd").format(Long
				.parseLong(bean.getDateline()) * 1000));
		holder.content.setText(bean.getComment());
		holder.wohuifudepinglun.setText(bean.getMessage());
		holder.tvname.setText("回复了您的帖子 ");
		// holder.commont.setText(bean.getReplies()); new
		// SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(Long.parseLong(
		// holder.iv1.setImageBitmap(null);
		// holder.iv2.setImageBitmap(null);
		// holder.iv3.setImageBitmap(null);

		return convertView;
	}

	class ViewHolder {
		ImageView head;
		ImageView iv1;
		ImageView iv2;
		ImageView iv3;

		TextView name, tvname;
		TextView time;
		TextView content;
		TextView zan;
		TextView commont;
		TextView wohuifudepinglun;
		ViewGroup imgsContainer;
	}

}
